extends RichTextLabel

var start_pos: Vector2
var velocity: Vector2
var gravity: float
var lifetime: float
var rot_speed: float
var rot_dir: int

func start_effect():
	var tween = create_tween()
	tween.tween_method(
		Callable(self, "_update_pop_effect"),
		0.0,
		lifetime,
		lifetime
	)

	tween.parallel().tween_property(self, "scale", Vector2(1.2, 1.2), 0.3).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)

func _update_pop_effect(progress: float) -> void:
	var new_pos = start_pos + velocity * progress + Vector2(0, 0.5 * gravity * progress * progress)
	position = new_pos
	modulate.a = 1.0 - (progress / lifetime)
	rotation = progress * rot_speed * rot_dir * 0.5
	if progress >= lifetime:
		queue_free()
